/*
 * @Author: huzhanglin 799490931@qq.com
 * @Date: 2023-12-16 19:08:25
 * @LastEditors: huzhanglin 799490931@qq.com
 * @LastEditTime: 2023-12-17 07:17:42
 * @FilePath: \my-app\src\app\pages\hero-child\hero-child.component.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { Component, Input } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Hero, Fruit } from '../common/Hero';
@Component({
  selector: 'app-hero-child',
  standalone: true,
  imports: [CommonModule],
  template: `
    <div>
      <h3>{{ hero.name }} says:</h3>
      <p>
        接收父组件数据 {{ hero.name }}, am at your service, {{ masterName }}.
      </p>
      <p>{{ address }}</p>
      <!-- ,,,,,,,,,,,<p>{{ _address }}</p> -->
      <div>
        <a *ngFor="let fruit of fruitsList">{{ fruit.name }} ,</a>
      </div>
    </div>
  `,
  styleUrl: './hero-child.component.css',
})
export class HeroChildComponent {
  @Input() hero!: Hero;
  @Input('master3') masterName = '';

  @Input()
  get address(): string {
    return this._address;
  }
  set address(address: string) {
    this._address = (address && address.trim()) || '<no name set>';
  }

  private _address = '';
  fruitsList = [
    new Fruit('apple', 20),
    new Fruit('orange', 30),
    new Fruit('pear', 40),
    new Fruit('banana', 50),
  ];
}
